package com.itbaizhan.provider;

import com.itbaizhan.pojo.User;

public class ProviderUser {
    //根据任意条件查询sql语句
    public String findByConditionSql(User user){
        StringBuffer stringBuffer = new StringBuffer(" select * from user where 1=1 ");
        /*注意空隔键 隔开*/
        if(user.getUsername().length()>0 && user.getUsername() != null){
            stringBuffer.append(" and username like #{username}");
        }
        if(user.getSex() != null && user.getSex().length() >0){
            stringBuffer.append(" and sex = #{sex}");
        }
        if(user.getAddress() != null && user.getAddress().length() > 0){
            stringBuffer.append(" and address = #{address}");
        }
        return stringBuffer.toString();
    }
}
